/**
 * Created by aaronjin on 16/11/24.
 */

var Unit=require('./unit.js');

const resolve = require('path').resolve;
module.exports = function (config,env) {
    var _cdn = require('../conf/cdn.json');
    var _port = require('../conf/port.json');
    try {
        config.devtool='cheap-module-source-map';
        config.resolve={
            modules: [
                'node_modules',
                resolve(__dirname, 'src'),
            ],
            extensions: ['.jsx', '.js', '.html', '.json']
        };
        if (env.ver == 'dev') {
            config.devtool='source-map';
            config.devServer= {
                host:_cdn[env.ver].replace('http://',''),
                inline:true,
                port: parseInt(_port[env.project]),
                contentBase: 'dist/',
                noInfo: true,
                historyApiFallback: true,
                hot:true
            };
        }

        return config;
    } catch (e) {
        throw new Error(e);
    }

};

